package cn.sczc.jh.client.service.securityMaterials;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cn.sczc.jh.client.entity.SecurityMaterials;
import cn.sczc.jh.client.mapper.securityMaterials.SecurityMaterialsMapper;

@Service
public class SecurityMaterialsService extends ServiceImpl<SecurityMaterialsMapper, SecurityMaterials>{
	@Autowired
	private SecurityMaterialsMapper securityMaterialsMapper;
	
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public Page<SecurityMaterials> queryList(Page<SecurityMaterials> page, Map<String, Object> params) {
		List<SecurityMaterials> list =  securityMaterialsMapper.queryList(page,params);
		page.setRecords(list);
		return page;
	}
	
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public List<SecurityMaterials> queryListNoPage(Map<String, Object> params) {
		return securityMaterialsMapper.queryListNoPage(params);
	}

	public Boolean insert(SecurityMaterials entity) {
		int a = 0;
		if (entity.getOid()!=null && !"".equals(entity.getOid())) {//修改
			a = securityMaterialsMapper.updateById(entity);
		}else {//新增
			entity.setOid(UUID.randomUUID().toString());
			entity.setCreateTime(new Date());
			a = securityMaterialsMapper.insert(entity);
		}
		return a==1;
	}

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public SecurityMaterials qryById(String id) {
		return securityMaterialsMapper.selectById(id);
	}

	public Boolean del(String id) {
		int a = 0;
		a = securityMaterialsMapper.deleteById(id);
		return a==1;
	}

	public void batchInsert(List<SecurityMaterials> smList) {
		securityMaterialsMapper.batchInsert(smList);
	}

	
	
}
